package cn.edu.sdu.sol.intake_system.controller;

import cn.edu.sdu.sol.intake_system.model.vo.DataRequest;
import cn.edu.sdu.sol.intake_system.model.vo.DataResponse;
import cn.edu.sdu.sol.intake_system.service.SuperAdminService;
import cn.edu.sdu.sol.intake_system.utils.VO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin(origins = "*", maxAge = 3600)
@RestController
@RequestMapping("/api/superAdmin")
public class SuperAdminController {

    VO vo = new VO();

    public boolean isLocked;
    @Autowired
    SuperAdminService superAdminService;

    @PostMapping("/getAdminList")
    public DataResponse getAdminList(){
        return superAdminService.getAdminList();
    }

    @PostMapping("/deleteAdmin")
    public DataResponse deleteAdmin(@RequestBody DataRequest req){
        return superAdminService.deleteAdmin(req);
    }

    @PostMapping("/addAdmin")
    public DataResponse addAdmin(@RequestBody DataRequest req){
        return superAdminService.addAdmin(req);
    }

    @PostMapping("/lock")
    public DataResponse lock(){
        isLocked = true;
        return vo.ok();
    }

    @PostMapping("/unlock")
    public DataResponse unlock(){
        isLocked = false;
        return vo.ok();
    }

}
